<script setup lang='ts'>
import { inject } from 'vue';

const realMoney = inject<number>('money', 0)
const costMoney = inject<(money: number) => void>('cost')

const cutMoney = () => {
    // 花爷爷的钱
    if (costMoney) {
        costMoney(5999)
    }
}

</script>

<template>
    <h3>我是孙子</h3>
    <p>得到爷爷给的零花钱：{{ realMoney }}</p>
    <button @click="cutMoney">想买一个华为的新手机</button>
</template>

<style scoped></style>